﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace ORS.Web
{
    public partial class UserRegester : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            ORS.BLL.processopr chkUser = new ORS.BLL.processopr();
            int isUser = chkUser.IsUserExisting("tb_userlist", txtID.Text,"");
            if(isUser == 1)
            {
                Response.Write("<script language=Javascript>alert(\"此用户名可使用！\")</script>");
            }else{
                Response.Write("<script language=Javascript>alert(\"此用户名已注册！\")</script>");
            }
        }

        protected void Bt_register_Click(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();
            ORS.BLL.Regester rs = new ORS.BLL.Regester();
            ht.Add("userid", rs.GetQuotedString(txtID.Text));
            ht.Add("password", rs.GetQuotedString(txtPwd.Text));
            ht.Add("cname", rs.GetQuotedString(txtName.Text));
            ht.Add("gender", rs.GetQuotedString(rblSex.SelectedValue));
            ht.Add("birthdate", rs.GetQuotedString(txtBirth.Text));
            ht.Add("department", rs.GetQuotedString(txtDepartment.Text));
            ht.Add("regdate",rs.GetQuotedString(DateTime.Now.ToShortDateString()));
            ht.Add("phonenum",rs.GetQuotedString(txtPhone.Text));
            ht.Add("mobilenum",rs.GetQuotedString(TxtMobile.Text));
            ht.Add("email",rs.GetQuotedString(txtMail.Text));
            ht.Add("roleid",rs.GetQuotedString(ddlRole.SelectedValue));
            ht.Add("interestid", rs.GetQuotedString(ddlinterest.SelectedValue));
            ht.Add("validflag",rs.GetQuotedString("0"));
            if(rs.userAdd(ht))
            {
                Response.Write("<script>alert('注册成功！');window.location='login.aspx';</script>");
            }
            else
            {
                Response.Write("<Script Language=JavaScript>alert(\"注册失败！\")</Script>");
            }
        }

        protected void Bt_reset_Click(object sender, EventArgs e)
        {
            FormsAuthentication.RedirectToLoginPage();
        }
    }
}